package inserter

import (
	"server/framework/orm/predicate"
	"server/framework/orm/session/dialect"
)

type UpdateBuilder[T any] struct {
	conflictColumns []predicate.Column
	Inserter        *Inserter[T]
}

func (u *UpdateBuilder[T]) SetConflictColumns(columns ...predicate.Column) *UpdateBuilder[T] {
	u.conflictColumns = columns
	return u
}

func (u *UpdateBuilder[T]) Update(Assignments ...predicate.Assignable) *Inserter[T] {
	u.Inserter.Updater = &dialect.Updater{
		ConflictColumns: u.conflictColumns,
		Assignments:     Assignments,
	}
	return u.Inserter
}
